const serverUrl = getApp().serverUrl
let user
Page({
  data: {
    user: null
  },

  onLoad: function (options) {
    user = wx.getStorageSync('user')
    this.setData({
      user: user
    })
  },

  toMyCode() {
    wx.navigateTo({
      url: '/pages/invitate/invitate',
    })
  },
  toAddress() {
    wx.navigateTo({
      url: '/pages/address/address',
    })
  },

  logout() {
    wx.showModal({
      title: '提示',
      content: '确定要退出吗',
      success(res) {
        if (res.confirm) {
          wx.removeStorageSync('token')
          wx.removeStorageSync('user')
          wx.redirectTo({
            url: '/pages/index/index',
          })
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  }
})